home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / BIASAXON / BKADJLIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.5 KB  |  49 lines

  1. // Dynamic link library implementation of BackLinearAxon with adaptible slope
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /* Backpropagation of component */
  6.  
  7. __declspec(dllexport) void performBackBiasAxon(
  8.     DLLData    *instance,        // Pointer to instance data
  9.     DLLData    *dualInstance,    // Pointer to the forward axons instance data
  10.     NSFloat    *data,             // Pointer to the layer of processing elements (PEs)
  11.     int     rows,            // Number of rows of PEs in the layer
  12.     int     cols,            // Number of columns of PEs in the layer
  13.     NSFloat    *error,         // Pointer to the sensitivity vector
  14.     NSFloat    *gradient         // Pointer to the bias gradient vector
  15.     )
  16.     
  17. {
  18.     int i,length=rows*cols;
  19.     NSFloat *beta = getWeights(dualInstance);
  20.     NSFloat *betaGradient = getWeights(instance);
  21.  
  22.     for (i=0; i<length; i++) {
  23.         error[i] *= beta[i];
  24.         if (betaGradient)
  25.             betaGradient[i] += error[i]*data[i];
  26.     }
  27. }
  28.  
  29. /******************************************/
  30. /* Management of instance data (OPTIONAL) */
  31.  
  32. __declspec(dllexport) DLLData *allocBackBiasAxon(
  33.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  34.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  35.     int     rows,            // Number of rows of PEs in the layer
  36.     int     cols            // Number of columns of PEs in the layer
  37.     )
  38. {
  39.     DLLData *instance = allocDLLInstance(oldInstance);
  40.     setWeights(instance, rows*cols);
  41.     return instance;
  42. }
  43.  
  44. __declspec(dllexport) void freeBackBiasAxon(DLLData *instance)
  45. {
  46.     freeDLLInstance(instance);
  47. }
  48.  
  49.